package springboot.amqp.service;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;
import springboot.amqp.entity.Book;

@Service
public class BookService {

    @RabbitListener(queues = {"atguigu.news"})
    void receive(Book book) {
        System.out.println(book);
    }

    @RabbitListener(queues = {"atguigu.news"})
    void receiveMessage(Message message) {
        Object body = message.getBody();
        MessageProperties messageProperties = message.getMessageProperties();
        String str = messageProperties.toString();
        System.out.println(body);
        System.out.printf(str);
    }
}
